<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Scan_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
		$this->CI = get_instance();
	}
	
	function get_scan_grid($arsip_tahun,$arsip_id){	
		$this->db->select('*');
		$this->db->from('ARSIP.ARSIP_FILE');
		$this->db->where('ARSIP_TAHUN',$arsip_tahun);
		$this->db->where('ARSIP_ID',$arsip_id);
		$this->db->where('STATUS',1);
		$this->CI->flexigrid->build_query();
		
		$return['records'] = $this->db->get();
		
		$this->db->select('*');
		$this->db->from('ARSIP.ARSIP_FILE');
		$this->db->where('ARSIP_TAHUN',$arsip_tahun);
		$this->db->where('ARSIP_ID',$arsip_id);
		$this->db->where('STATUS',1);
		$this->CI->flexigrid->build_query(FALSE);
		
		$return['record_count'] = $this->db->count_all_results();

		return $return;
	}

	function count_all_scan(){
		$this->db->select('*');
		$this->db->from('ARSIP.ARSIP_FILE');
		$query = $this->db->get();
		return $query->num_rows();
	}

	function add_scan($data){
		$this->db->insert('ARSIP_FILE',$data);
	}

	function update_scan($data,$arsip_id){
		$this->db->where('FILE_ID',$arsip_id);
		$this->db->update('ARSIP_FILE',$data);
	}

	function delete_scan($arsip_id){
		$data = array(
			'STATUS' 			=> 0
		);
		$this->db->where('FILE_ID',$arsip_id);
		$this->db->update('ARSIP_FILE',$data);
	}

	function get_scanID($FILE_ID){
		$this->db->select('*');
		$this->db->from('ARSIP_FILE');
		$this->db->where('FILE_ID',$FILE_ID);
		$query = $this->db->get();
		return $query;
	}
}

?>